package com.zb.vo;

import com.zb.annotation.NumberPattern;
import com.zb.utils.VerificUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

/**
 * @Author WEN
 * @Date 2024/1/8 0008
 **/
@Data
@ApiModel("仓库出入库物料对象")
public class StoreBoundMaterialVo {
    @ApiModelProperty(value = "出入库物料ID，新增不必传，修改必传")
    private Long id;

    @NotNull(message = "物料类型不能为空")
    @NumberPattern(regexp = "[1|2]", required = true, message = "物料类型参数不合法")
    @ApiModelProperty(value = "物料类型：1-成品 ，2-配件", required = true, example = "1")
    private Integer type;

    @NotNull(message = "仓库不能为空")
    @ApiModelProperty(value = "仓库ID", required = true)
    private Long storeId;

    @ApiModelProperty(value = "仓库仓位ID，当仓库启用仓位时，此字段必传", example = "0")
    private Long storePositionId;

    @NotNull(message = "物料不能为空")
    @ApiModelProperty(value = "物料ID", required = true)
    private Long goodsId;

    @NotNull(message = "物料规格不能为空")
    @ApiModelProperty(value = "物料规格ID", required = true)
    private Long goodsSpecId;

    @NotNull(message = "物料单价不能为空")
    @NumberPattern(regexp = VerificUtil.FLOATING_NUMBER_10_2, message = "物料单价最多允许输入8位整数，两位小数")
    @ApiModelProperty(value = "物料单价", required = true, example = "0.0")
    private BigDecimal price;

    @NotNull(message = "物料数量不能为空")
    @NumberPattern(regexp = "^[1-9]?$|^([1-9][0-9]){1,8}$", required = true, message = "物料数量不能为空，且必须 >= 1，且最大长度限制8个字符")
    @ApiModelProperty(value = "物料出/入库数量", required = true, example = "1")
    private long qty;

    @ApiModelProperty(value = "物料出/入库备注")
    private String remark;

    @Valid
    @NotNull(message = "物料商品一物一码不能空")
    @NotEmpty(message = "物料商品一物一码不能空")
    @ApiModelProperty(value = "物料商品一物一码对象")
    private List<StoreGoodsStockCodeVo> stockCodeVos;

}
